<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function* test() {
        console.log("第一次运行");
        yield 1;
        console.log("第二次运行");
        yield 2;
        console.log("第三次运行");
      }

      const generator = test();
      console.log(generator);
      console.log(generator.next());
      console.log(generator.next());
    </script>
  </body>
</html>
